package com.weijianhuawen.wjblog.web.convert;

import com.weijianhuawen.wjblog.common.domain.dos.ArticleDo;
import com.weijianhuawen.wjblog.web.mode.vo.archive.FindArchiveArticleRspVo;
import com.weijianhuawen.wjblog.web.mode.vo.article.FindIndexArticlePageListRspVo;
import com.weijianhuawen.wjblog.web.mode.vo.category.FindCategoryArticlePageListRspVo;
import com.weijianhuawen.wjblog.web.mode.vo.tag.FindTagArticlePageListReqVo;
import com.weijianhuawen.wjblog.web.mode.vo.tag.FindTagArticlePageListRspVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-10-28 18:27
 */

@Mapper
public interface ArticleConvert {
    //  初始号convert实例
    ArticleConvert INSTENCE = Mappers.getMapper(ArticleConvert.class);

    // 将do 转换成 vo
    FindIndexArticlePageListRspVo convertDoToVo(ArticleDo bean);

    // 将do 转换成 archive vo
    @Mappings({
            @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))"),
            @Mapping(target = "createMonth", expression = "java(java.time.YearMonth.from(bean.getCreateTime()))")
    })
    FindArchiveArticleRspVo convertDoToArchiveVo(ArticleDo bean);

    // 将do 转换为 分类文章列表vo
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindCategoryArticlePageListRspVo convertDoToCategoryArticleVo(ArticleDo bean);

    // 将do转换为 标签文章列表vo
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindTagArticlePageListRspVo convertDoToTagArticleVo(ArticleDo bean);
}
